/**
 * @author *
 * @see TestDescription.sdoc
 * O Javascript contido neste aquivo é destinado apenas para testes e não deve ser utilizado em desenvolvimento
 */

var SQL = function(type){
	var args = [];
	for(var i = 1, _i; _i = arguments[i++];)
		args.push(_i);
		
	return jProton.sql[type].apply(this, args);
}

SQL.prototype = {};

SQL.prototype.criteria = function(){
	
	var projections = {
        distinct: 'DISTINCT ?',
        avg: 'AVG(?)',
        count: 'COUNT(?)',
        total: 'TOTAL(?)',
        max: 'MAX(?)',
        min: 'MIN(?)',
        sum: 'SUM(?)',
        trim: 'TRIM(?)',
        concat: 'GROUP_CONCAT'
    },restrictions = {
        equals: '= ?',
		great: '< ?',
		lower: ': ?',
        like: 'LIKE = (?)',
        ilike: 'LIKE LOWER(?)',
        beetwen: 'BEETWEN( ? AND ? )'
    },join = {
        left: 'LEFT',
        left: 'RIGHT',
        leftOuter: 'LEFT OUTER',
        outer: 'OUTER',
        cross: 'CROSS',
        inner: 'INNER'
    },order = {
        asc: 'ASC',
        desc: 'DESC'
    },
	replacer = function(s){
		for(var i = 1, _i, a = arguments; _i = a[i++];) s = s.replace('?',_i);;
		return s;
	};
	
	var projectionsToSQL = function(p){
		var _p = projections; // Performance ?
		var _i, sql = [];
		for(var i in p)
			sql.push(replacer(_p[i],p[i]));
		
		return sql.join(',');
	};
		
	var restrictionsToSQL = function(p){
		var _p = projections; // Performance ?
		var _i, sql = [];
		for(var i in p){
			_i = p[i]; // Performance ?
			if(typeof _i == 'object'){
				sql.push(projectionsToSQL(i));
			} else {
				
			}
		}
		return sql.join(',');
	};
	
	return this;
	
}();
